home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / program / tpwpxeng.zip / SRCHKEY.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-22  |  940b  |  39 lines

  1. program SrchKey;
  2. uses PXEngine, WinCrt;
  3.  
  4. const TableName = 'Table';
  5.       Search    = 'SearchString';
  6.  
  7. var   PxErr: Integer;
  8.       TblHandle: TableHandle;
  9.       RecHandle: RecordHandle;
  10.       FldHandle: FieldHandle;
  11.       NFlds: Word;
  12.  
  13. procedure PX(Code : integer);
  14. begin
  15.   writeln(PXErrMsg(Code));
  16. end;
  17.  
  18. begin
  19.   PX(PXWinInit('MyApp', pxShared));
  20.   NFlds := 1;
  21.  
  22.   PX(PXTblOpen(TableName, TblHandle, 0, False));
  23.   PX(PXRecBufOpen(TblHandle, RecHandle));
  24.   PX(PXFldHandle(TblHandle, 'Alpha Field', FldHandle));
  25.   PX(PXPutAlpha(RecHandle, FldHandle, Search));
  26.  
  27.   (* Search for match on a key *)
  28.   PxErr := PXSrchKey(TblHandle, RecHandle, NFlds, SearchFirst);
  29.   if PxErr <> PxSuccess then
  30.     if PxErr = PxErr_RecNotFound then
  31.       Writeln('No match found')
  32.     else Writeln(PxErrMsg(PxErr))
  33.   else Writeln('Match found');
  34.  
  35.   PX(PXRecBufClose(RecHandle));
  36.   PX(PXTblClose(TblHandle));
  37.   PX(PXExit);
  38. end.
  39.